package com.TTBook.impl.book.daoImpl;

import com.TTBook.core.book.dao.BookStorageDAO;
import com.TTBook.core.book.model.BookStorage;
import com.TTBook.core.book.model.BookStorageCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BookStorageDAOImpl extends SqlMapClientDaoSupport implements BookStorageDAO {

    public BookStorageDAOImpl() {
        super();
    }

    public int countByCriteria(BookStorageCriteria criteria) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("ts_book_storage.countByCriteria", criteria);
        return count.intValue();
    }

    public int deleteByCriteria(BookStorageCriteria criteria) {
        int rows = getSqlMapClientTemplate().delete("ts_book_storage.deleteByCriteria", criteria);
        return rows;
    }

    public int deleteByPrimaryKey(String bookid) {
        BookStorage key = new BookStorage();
        key.setBookid(bookid);
        int rows = getSqlMapClientTemplate().delete("ts_book_storage.deleteByPrimaryKey", key);
        return rows;
    }

    public void insert(BookStorage record) {
        getSqlMapClientTemplate().insert("ts_book_storage.insert", record);
    }

    public void insertSelective(BookStorage record) {
        getSqlMapClientTemplate().insert("ts_book_storage.insertSelective", record);
    }

    public List selectByCriteria(BookStorageCriteria criteria) {
        List list = getSqlMapClientTemplate().queryForList("ts_book_storage.selectByCriteria", criteria);
        return list;
    }

    public BookStorage selectByPrimaryKey(String bookid) {
        BookStorage key = new BookStorage();
        key.setBookid(bookid);
        BookStorage record = (BookStorage) getSqlMapClientTemplate().queryForObject("ts_book_storage.selectByPrimaryKey", key);
        return record;
    }

    public int updateByCriteriaSelective(BookStorage record, BookStorageCriteria criteria) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, criteria);
        int rows = getSqlMapClientTemplate().update("ts_book_storage.updateByCriteriaSelective", parms);
        return rows;
    }

    public int updateByCriteria(BookStorage record, BookStorageCriteria example) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
        int rows = getSqlMapClientTemplate().update("ts_book_storage.updateByCriteria", parms);
        return rows;
    }

    public int updateByPrimaryKeySelective(BookStorage record) {
        int rows = getSqlMapClientTemplate().update("ts_book_storage.updateByPrimaryKeySelective", record);
        return rows;
    }

    public int updateByPrimaryKey(BookStorage record) {
        int rows = getSqlMapClientTemplate().update("ts_book_storage.updateByPrimaryKey", record);
        return rows;
    }

    private static class UpdateByCriteriaParms extends BookStorageCriteria {
        private Object record;

        public UpdateByCriteriaParms(Object record, BookStorageCriteria criteria) {
            super(criteria);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}